﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace RandomPuzzle
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : RandomPuzzle
    {
        public int[] GetRandomPuzzle()
        {
            SudokuState.SudokuState state = SudokuState.SudokuState.ExampleState();

            int[][] puzzle = state.ToArray();
            SolverLibrary.Data_Entities.SudokuBoard board = new SolverLibrary.Data_Entities.SudokuBoard();
            for (int row = 0; row < puzzle.Length; row++)
            {
                board.insertRow(puzzle[row], row);
            }
            SolverLibrary.Data_Entities.SudokuPuzzle sudokuPuzzle = new SolverLibrary.Data_Entities.SudokuPuzzle(board);
            SolverLibrary.Data_Entities.Board solvedBoard = sudokuPuzzle.solve();
            int[,] twoDem = solvedBoard.getTwoDimensional();
            Random random = new Random();

            for (int i = 0; i < 20; i++)
            {
                int rand1 = random.Next(0, 8);
                int rand2 = random.Next(0, 8);
                twoDem[rand1, rand2] = 0;
            }


            return twoDem.Cast<int>().ToArray();

        }
    }
}
